package cz.muni.fi.pa165.sme.web.pages.burnedCalories;

import cz.muni.fi.pa165.sme.web.fo.BurnedCaloriesFO;
import cz.muni.fi.pa165.sme.web.pages.TemplatePage;
import cz.muni.fi.pa165.sme.web.panels.burnedCalories.CaloriesForm;
import org.apache.wicket.authorization.Action;
import org.apache.wicket.authroles.authorization.strategies.role.Roles;
import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeAction;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.model.ResourceModel;

/**
 * @author jirankova
 */
@AuthorizeAction(action = Action.RENDER, roles = { Roles.ADMIN})
public class CaloriesEditPage extends TemplatePage {

	public CaloriesEditPage(final BurnedCaloriesFO burnedCaloriesFO) {
		add(new Label("title", new ResourceModel("calories.edit.title")));

		final CompoundPropertyModel<BurnedCaloriesFO>
				recordModel = new CompoundPropertyModel<BurnedCaloriesFO>(new LoadableDetachableModel<BurnedCaloriesFO>() {
			@Override
			protected BurnedCaloriesFO load() {
				return burnedCaloriesFO;
			}
		});

		add(new CaloriesForm("form", recordModel));
	}
}
